//
//  HomeViewController.m
//  opentest
//
//  Created by wuzhx on 2017/12/14.
//  Copyright © 2017年 wuzhx. All rights reserved.
//

#import "HomeViewController.h"
#import "HomeDetailViewController.h"

@interface HomeViewController ()

@property (strong, nonatomic) UILabel *lbContent;
@property (strong, nonatomic) UIButton *btnDetail;

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.lbContent];
    [self.view addSubview:self.btnDetail];
    [self addViewConstraints];
}

- (void)addViewConstraints
{
    [self.lbContent mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.left.greaterThanOrEqualTo(self.view).offset(12);
        make.right.lessThanOrEqualTo(self.view).offset(-12);
    }];
    
    [self.btnDetail mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.lbContent.mas_bottom).offset(10);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Actions
- (void)btnDetailAction:(UIButton *)btn
{
    HomeDetailViewController *vc = [[HomeDetailViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - NSObject
- (UILabel *)lbContent
{
    if (!_lbContent) {
        _lbContent = [[UILabel alloc] init];
        _lbContent.numberOfLines = 0;
        _lbContent.textAlignment = NSTextAlignmentCenter;
        _lbContent.text = @"2.1.1版本功能开发结束";
    }
    return _lbContent;
}

- (UIButton *)btnDetail
{
    if (!_btnDetail) {
        _btnDetail = [UIButton buttonWithType:UIButtonTypeSystem];
        [_btnDetail addTarget:self action:@selector(btnDetailAction:) forControlEvents:UIControlEventTouchUpInside];
        [_btnDetail setTitle:@"详情页" forState:UIControlStateNormal];
        [_btnDetail setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    }
    return _btnDetail;
}

@end
